package day17_thread_local;

import java.util.List;

/**
 * @author xinxing
 * @date 2023/2/9 13:08
 */
public class ThreadLocalTest {

    private List<String> messages;

    public final static ThreadLocal<ThreadLocalTest> local = ThreadLocal.withInitial(ThreadLocalTest::new);

    public static void add(String message) {
        local.get().messages.add(message);
    }

    public static List<String> clear() {
        local.get().messages.clear();

        return local.get().messages;
    }

    public static void main(String[] args) throws NoSuchFieldException {

        Thread thread = Thread.currentThread();
        Class<? extends Thread> aClass = thread.getClass();
        aClass.getDeclaredField("threadLocals");

    }

}
